package com.jdiv.samples.zelda;

import com.jdiv.JProcess;

public class Link extends JProcess {

//PRIVATE
private int DIRECCION_PARADO;
private int C_ABAJO=1;
private int C_ARRIBA=12;
private int C_IZQ=23;
private int C_DER=34;
private int x_tmp;
private int y_tmp;
private int mp;

//BEGIN
	public Link() {
		super();
		graph=1;
		x=10;
		y=10;
	}
	public void begin(){}
//LOOP	
	public void loop() {

		if(key(_DOWN)){
	       y+=3;  C_ABAJO++;
	        if(C_ABAJO==11) C_ABAJO=1; else graph=C_ABAJO;
	       DIRECCION_PARADO=1;
		}

		if(key(_UP)){
	       y-=3;  C_ARRIBA++;
	       if(C_ARRIBA==22) C_ARRIBA=12; else graph=C_ARRIBA;
	       DIRECCION_PARADO=2;
		}

		if(key(_LEFT)){
	       x-=3; C_IZQ++;
	       if(C_IZQ==33) C_IZQ=23; else graph=C_IZQ;
	       DIRECCION_PARADO=3;
		}

		if(key(_RIGHT)){
			x+=3; C_DER++;
	       if(C_DER==44) C_DER=34; else graph=C_DER;
	       DIRECCION_PARADO=4;
		}  		

		// 1=ABAJO // 2=ARRIBA // 3=IZQ // 4=DER //
		if(key(_SPACE)){
			
		     switch(DIRECCION_PARADO){
		      case 1: 
		         for (graph=45;graph<=52;graph++){
		        	 frame();
		         }
		         graph=C_ABAJO;
		       break;
		      case 2: 
		    	   for (graph=53;graph<=60;graph++){
		    		   frame(); 
		    	   }
		            graph=C_ARRIBA;
		       break;
		       case 3: 
		            for (graph=61;graph<=68;graph++){
			        	 frame();
			         }
		              graph=C_IZQ;
		       break;
		       case 4: 
		    	   for (graph=69;graph<=76;graph++){
			        	 frame();
			         }
		           graph=C_DER;
		       break;
		     }
		     
		  }
		        
	          
		
	}

}
